tbody.addEventListener('click',function(e){
	const target=e.target
	const classes=Array.from(target.classList)
	const tr=target.parentNode.parentNode
	if(classes.includes('btn-edit')){
		tr.classList.add('edit')
		const spans=tr.querySelectorAll('span')
		spans.forEach(span=>{
			span.nextElementSibling.value = span.innerHTML
		})
	}else if(classes.includes('btn-ok')){
		const id=tr.getAttribute('data-id')
		const name=tr.querySelector('.inputName').value
		const price=tr.querySelector('.inputPrice').value 
		const num=tr.querySelector('.inputNum').value
		utils.fetch('./api/shop/update.php',{id, name, price, num}).then(resp=>{
			if(resp.code===200){
				tr.classList.remove('edit')
				const spans=tr.querySelectorAll('span')
				spans.forEach(span=>{
					span.innerHTML=span.nextElementSibling.value
				})
			}
		})
	}else if(classes.includes('btn-cancle')){
		tr.classList.remove('edit')
	}else if(classes.includes('btn-del')) {
		const id=tr.getAttribute('data-id')
		utils.fetch('./api/shop/delete.php',{id}).then(resp=>{
			if(resp.code===200){
				alert("确定删除吗？")
				tr.remove()
				getData()
			}
		})
	}
})




